import axios from 'axios';
import config from '@/../src/config/index';

const defaultWmsUrl = process.env.NODE_ENV === 'development'
    ? config.wmsUrl.dev
    : process.env.VUE_APP_MODE === 'testEnvironment'
        ? config.wmsUrl.dev
        :  process.env.VUE_APP_MODE === 'temporary'
            ? config.wmsUrl.temporary
            :  process.env.VUE_APP_MODE === 'prod'
                ? config.wmsUrl.pro
                : config.wmsUrl.dev;

// 字典接口
export function getByCodeTableTypeList(wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/customs_code_table/getByCodeTableType',
        method: 'get',
        parameter: {
            type: 'WMS'
        }
    });
}


// 新增保存
export function receivePushApplyInfoHandler(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/receivePushApplyInfoHandler',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 获取库存列表
export function getStockListByOwnerCode(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_stock/getStockListByOwnerCodeForLenglianClient',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 编辑保存接口
export function updatePushApplyInfoHandler(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/updatePushApplyInfoHandler',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 查询客户
export function selectByCustomerType(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_customer/selectByCustomerType',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 货物列表
export function selectList(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/selectList',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 删除计划
export function deleteById(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/deleteById',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 获取商品信息
export function getGoodsInfo(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/customs_declare_business/getGoodsInfo',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 判断是否有虚拟库存
export function checkIfExistVirtualStock(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_stock/checkIfExistVirtualStock',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 查询附件列表
export function getFileList(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_file/page',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 保存附件
export function saveFileList(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_file',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 提交保税
export function updateApplyStatus(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/updateApplyStatus',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}

// 删除附件
export function deleteFile(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/wms_file/deleteFile',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    })
}


// EDOC下载
export function customerDownload(body,wmsUrl= defaultWmsUrl) {
    return axios({
        url:  wmsUrl + '/api/wms_file/customerDownload',
        method: 'POST',
        parameter: {
            type: 'WMS'
        },
        data: body,
        responseType: 'blob'
    });
}

// 导出附件模板
export function exportTemplate(wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/exportTemplate',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        responseType: 'blob'
    });
}

// 导入附件模板
export function importTemplate(wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/importTemplate',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        responseType: 'blob'
    });
}

export function getCustomsStatisticData(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/receive_ccis_order/getCustomsStatisticData',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body
    });
}

export function selectBoxNumPage(body, wmsUrl= defaultWmsUrl) {
    return axios({
        url: wmsUrl + '/api/ccis_apply_summary/selectBoxNumPage',
        method: 'post',
        parameter: {
            type: 'WMS'
        },
        data: body,
    });
}


